﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BitPortal.Business;

namespace BitPortal.Modules.PasswordRecovery
{
    public partial class PasswordRecovery : Controls.BaseUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void imgOk_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtName.Text.Trim().Length <= 0 || txtName.Text.Trim().Length > 100)
                {
                    throw new Exception(Resources.BitResources.Feedback_NameNotValid);
                }
                if (Session["captcha"] == null || !txtcaptcha.Text.Equals(Session["captcha"].ToString(), StringComparison.OrdinalIgnoreCase))
                {
                    throw new Exception(Resources.BitResources.Feedback_CaptchaNotValid);
                }

                if (UserBLL.ResetPassword(txtName.Text) != null)
                {
                    RegisterScript("ShowStatus()");
                }
                //Reset Captcha
                Session["captcha"] = null;

            }
            catch (Exception ex)
            {
                (this.Page as Controls.BaseFrontendPage).ShowArlert(ex.Message);
            }
        }

    }
}